How to reload google dfp in ajax content? [migrated]

Posted by cj333 on Pro Webmasters See other posts from Pro Webmasters or by cj333
Published on 2012-09-24T17:15:54Z Indexed on 2012/09/24 21:50 UTC
Read the original article Hit count: 398

Filed under:
|

google dfp support ads in ajax content, but if I parse all the code in main page. it always show the same ads even turn page reload the ajax content. I read some article from http://productforums.google.com/forum/#!msg/dfp/7MxNjJk46DQ/4SAhMkh2RU4J. But my code not work. Any work code for suggestion? Thanks.

Main page code:

<script type='text/javascript'>
$(document).ready(function(){
$('#next').live('click',function(){
var num = $(this).html();
$.ajax({
   url: "album-slider.php",
   dataType: "html",
   type: 'POST',
   data: 'photo=' + num,
   success: function(data){ 
       $("#slider").center();
       googletag.cmd.push(function() {
       googletag.defineSlot('/1*******/ads-728-90', [728, 90], 'div-gpt-ad-1**********-'+ num).addService(googletag.pubads());
       googletag.pubads().enableSingleRequest();
       googletag.enableServices();
});
   }                
});
});
});
</script>

album-slider.php

<!-- ads-728-90 -->
<div id='div-gpt-ad-1**********-<?php echo $_GET['photo']; ?>' style='width:728px; height:90px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1**********-<?php echo $_GET['photo']; ?>); });
</script>

© Pro Webmasters or respective owner

Related posts about google-adsense

Related posts about AJAX